<template>
	<div class="select-patient">
		<el-dialog title="选择病人" custom-class="a-el-dialog" :visible.sync="visible" width="300px" append-to-body>
			<AElForm ref="AElForm" :data="form" :rows="1" labelWidth="85px" />
			<span slot="footer" class="dialog-footer">
				<el-button @click="visible = false">取 消</el-button>
				<el-button type="success" @click="submit">确定</el-button>
			</span>
		</el-dialog>
		<EditingSchedule ref="EditingSchedule" type="1" />
	</div>
</template>

<script>
import EditingSchedule from '../editingSchedule'; // 编辑排班信息
export default {
	name: 'SelectPatient',
	components: { EditingSchedule },
	props: {
		patientList: { type: Array, default: () => [] }, // 病人信息列表
	},
	data() {
		return {
			visible: false, // 是否显示编辑排班信息弹窗
			form: {}
		}
	},
	created() {
		this.setForm();
	},
	methods: {
		/**
		 * 修改visible
		 */
		editVisible(value = false) {
			this.visible = value;
			this.resetForm();
		},
		/**
		 * 表单配置
		 */
		setForm() {
			this.form = {
				therapistName: {
					label: "病人",
					type: "select",
					rules: [{ required: true, message: '请选择病人', trigger: 'blur' }],
					children: [
						{
							label: "张飞吃豆芽",
							value: "0"
						}
					]
				}
			}
		},
		/**
		 * 重置表单
		 */
		resetForm() {
			// 将操作丢到微任务中
			this.$nextTick(() => {
				let form = this.$refs.AElForm.resetForm();
				console.log(form, "form");
			})
		},
		/**
		 * 病人确定
		 */
		submit() {
			this.$refs.AElForm.validateForm((flag, form) => {
				if (flag) {
					this.$refs.EditingSchedule.editVisible(true);
				}
			});
		}
	}
}
</script>

<style lang="scss" scoped>
@import url('./index.scss');
</style>